home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacFormat España 20
/
macformat_20.iso
/
mac
/
Shareware
/
Desarrolladores
/
Sprite Animation Toolkit 2.3.8
/
Demos
/
FastLoad Demo ƒ
/
FastLoadDemo.p
< prev
Wrap
Text File
|
1996-06-23
|
2KB
|
78 lines
program FastLoadDemo;
{A demo/test program showing how to load a large number of faces from PICT resources with}
{minimal overhead. There are some parts missing - row start tables to be precise - and you}
{could possibly take the mask regions out. It all depends on your needs. If you plan to use SAT's}
{blitters all the time (i.e. SATRun(true) you can remove the regions.}
{This program will ONLY work in 256 colors or more! In B/W or 4-bit color, there are additional}
{data needed since SAT does certain special optimizing for those depths. I have tested it in 256}
{and thousands of colors, and it will probably run out of memory in millions.}
{This program does no error checking! You will have to add that to use it in a real program!}
{/Ingemar Ragnemalm december 1995}
{Revised may 1996, in order to clean up, add more options, and make FaceLoad a stand-alone}
{reusable module.}
uses
{$ifc UNDEFINED THINK_PASCAL}
Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps,{}
Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus, Resources, StandardFile,{}
GestaltEqu, Files, Errors, Devices,
{$endc}
SAT, FastLoad;
var
ppsprite: Sprite;
sptr: SpritePtr;
faces: FaceArrPtr;
h, v: Integer;
procedure Nop (me: SpritePtr);
begin
end;
begin
{$IFC UNDEFINED THINK_PASCAL}
SATInitToolbox;
{$ENDC}
SATInit(128, 128, 400, 300);
{Load the faces!}
SysBeep(1);
faces := Load2DFaceArray(129, 130, 100, 32, 32, 10, true, true);
SysBeep(1);
{I use SATNewSpritePP here. That has no connection to the face loading - I could just as well}
{use SATNewSprite as usual! Consider this a little demonstration of SATNewSpritePP thrown in}
{"for free".}
sptr := SATNewSpritePP(nil, @ppsprite, 0, 0, 0, nil);
ppsprite.task := @Nop;
ppsprite.face := nil;
SATSetPortScreen;
HideCursor;
while not Button do
begin
{Set the face of the sprite to one of the 100 sprites in the faces array, depending on mouse position.}
GetMouse(ppsprite.position);
h := ppsprite.position.h * 10 div gSAT.offSizeH;
if h < 0 then
h := 0;
if h > 9 then
h := 9;
v := ppsprite.position.v * 10 div gSAT.offSizeV;
if v < 0 then
v := 0;
if v > 9 then
v := 9;
ppsprite.face := @faces^[h + v * 10];
SATRun(false);
end;
ShowCursor;
end.